package com.my.study.designPatterns.compoundPattern;

public class DuckSimulator {

    public static void main(String[] args) {

        DuckSimulator simulator = new DuckSimulator();
        AbstractDuckFactory abstractDuckFactory = new DuckFactory();
        simulator.simultate(abstractDuckFactory);
    }


    public void simultate(AbstractDuckFactory duckFactory){


        Quackable green = duckFactory.greenDuck();
        Quackable red = duckFactory.redDuck();
        Quackable yellow = duckFactory.yellowDuck();

        Flock flock = new Flock();
        flock.add(green);
        flock.add(red);
        flock.add(yellow);


        System.out.println("\n Duck Simulator: With Observer");


        Quackologist quackologist = new Quackologist();
        flock.registerObserver(quackologist);

        simulate(flock);

        System.out.println("\n The ducks quacked" + QuackCounter.numberOfQuack + "   times");


    }

    public void simulate(Quackable duck){
        duck.quack();
    }
}
